package com.keti.controller;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.keti.Dao.UserDao;
import com.keti.DaoImpl.UserDaoImpl;
import com.keti.pojo.User;


/**
 * Servlet implementation class Sign_inServlet
 */
@WebServlet("/Sign_inServlet")
public class Sign_inServlet extends HttpServlet {
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		 request.setCharacterEncoding("utf-8");
		  response.setContentType("text/html;charset=utf-8");
		  String account = request.getParameter("account");
		  String password = request.getParameter("password");
		  String name = request.getParameter("name");
		  String sex = request.getParameter("sex");
		  int age = Integer.parseInt(request.getParameter("age"));
		  String department = request.getParameter("department");
		  User u = new User();
		  u.setAccount(account);
		  u.setPassword(password);
		  u.setName(name);
		  u.setSex(sex);
		  u.setAge(age);
		  u.setIdentity("用户");
		  u.setDepartment(department);
		  UserDao ud = new UserDaoImpl();
		  ud.add(u);
		  response.sendRedirect("/RecipientsSystem/jsp/Login.jsp");
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		doGet(request, response);
	}

}
